package com.owen.server.impl;

import com.owen.dao.UserDao;
import com.owen.pojo.Fruits;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.concurrent.TimeUnit;

public class textRedis {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private UserDao userDao;

    @Test
    public void contextLoads() {
        Fruits fruits1 = new Fruits(1L ,"北京", "苹果");
        Fruits fruits2 = new Fruits(2L ,"天津", "香蕉");
        Fruits fruits3 = new Fruits(3L ,"上海", "猕猴桃");
        Fruits fruits4 = new Fruits(4L ,"广州", "水蜜桃");
        Fruits fruits5 = new Fruits(5L ,"深圳", "黄桃");
        Fruits fruits6 = new Fruits(6L ,"湖北", "柚子");
        Fruits fruits7 = new Fruits(7L ,"四川", "橘子");
        Fruits fruits8 = new Fruits(8L ,"西藏", "草莓");
        ListOperations listOperations = redisTemplate.opsForList();
        Long users = listOperations.leftPushAll("fruits", fruits1, fruits2, fruits3, fruits4, fruits5, fruits6, fruits7, fruits8);
        System.out.println(users);

    }


    @Test
    public void test() {
        ListOperations listOperations = redisTemplate.opsForList();
        List fruits = listOperations.range("fruits", 0, -1);

        for (Object fruit : fruits) {
            System.out.println(fruit);
        }






    }

}
